package org.lib.mysqlhello.tcache.try1;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 书
 * 使用Redis缓存时，Book类必须implements Serializable！！
 * @author ben
 * @date 2021-08-26 10:34:44 CST
 */
@Entity
@NoArgsConstructor
@Data
//public class Book implements Serializable {
public class Book {

	/**
	 * serialVersionUID
	 */
//	private static final long serialVersionUID = 210826L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	/**
	 * 书名
	 */
	@Column(columnDefinition = "VARCHAR(500) NOT NULL")
	private String name;
	/**
	 * 作者
	 */
	@Column(columnDefinition = "VARCHAR(100) NOT NULL")
	private String author;
	/**
	 * 销量
	 */
	@Column(columnDefinition = "INT DEFAULT 0")
	private Integer sales;
	
	/**
	 * 构造函数
	 * @param name
	 * @param author
	 */
	public Book(String name, String author) {
		this.name = name;
		this.author = author;
		this.sales = 0;
	}
	
}
